package com.company.merge;

import java.util.Arrays;

public class Test1 {

	public static void main(String[] args) {
		int[] a1 = {1,4,8,6,9,10};
		int[] a2 = {2,5,7,1,3,6,8,9,4,2,1,5,10};
//		Arrays.sort(a1);
//		Arrays.sort(a1);
		
		int len1 = a1.length;
		int len2 = a2.length;
		int len3 = len1 > len2 ? len1 : len2;
		
		int[] con = new int[len3];
		int m = 0;
		for(int i= 0;i<len1;i++){
			for(int j=i;j<len2;j++){
				if(a1[i] == a2[j]){
					con[m] = a1[i];
					m++;
				}
			}
		}
		
		for(int j = 0;j < con.length; j++)
		     System.out.print(con[j]+" ");
		
	}

}
